package com.itheima.reggie.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.dto.OrdersDto;
import com.itheima.reggie.pojo.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface OrdersMapper extends BaseMapper<Orders> {

    /**
     * 查询用户最新订单和订单详情(连接查询)
     * @param page
     * @param userId
     * @return
     */
    Page<OrdersDto> queryUserOrderByPage(@Param("page") Page<OrdersDto> page, @Param("userId") Long userId);

    /**
     * 查询用户最新订单和订单详情(嵌套查询)
     * @param page
     * @param userId
     * @return
     */
    Page<OrdersDto> queryUserOrderNestDetail(@Param("page") Page<OrdersDto> page,
                                             @Param("userId") Long userId);

    /**
     * 根据订单id查询订单和订单明细
     * @param id
     * @return
     */
    OrdersDto queryOrdersDtoById(Long id);
}
